#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;
const int N = 1e5 + 10;
int n;
int a[N], b[N], c[N];
int bserch_a(int i)
{
    int l = 0, r = n - 1;
    while (l < r)
    {
        int mid = l + r + 1 >> 1;
        if (a[mid] < b[i]) l = mid;
        else r = mid - 1;
    }
    if (a[l] < b[i]) return l + 1;
    else return 0;
}
int bserch_c(int i)
{
    int l = 0, r = n - 1;
    while (l < r)
    {
        int mid = l + r >> 1;
        if (c[mid] > b[i]) r = mid;
        else l = mid + 1;
    }
    if (c[l] > b[i]) return n - l;
    else return 0;
}
int main()
{
    cin >> n;
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a, a + n), sort(c, c + n);
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        ans += (ll)bserch_a(i) * bserch_c(i);
    }
    cout << ans << endl;
    return 0;
}